package Interceptadores;

import java.sql.SQLException;
import java.util.ArrayList;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

import dnaController.action.PesquisaController;
import dnaDAO.Doenca.DoencaDAO;
import dnaModel.Doenca;

@SuppressWarnings("serial")
public class InterceptadorListarDoencas extends AbstractInterceptor {

	public String intercept(ActionInvocation invocation) throws Exception {
	
		ArrayList<Doenca> doencas = new ArrayList<Doenca>(); 
		try {
			doencas = DoencaDAO.getInstance().listar();
		} catch (SQLException e) {
			return "error";
		}
		
		PesquisaController action = (PesquisaController)invocation.getAction();
		action.setDoencas(doencas);	
		
	    return invocation.invoke();
	}
}

